import { memo } from 'react';
import { Route, Routes, Navigate } from 'react-router-dom'
// import history from './history';
// 引入路由表
import routes from './routes'

function Router(){
  return <>
    <Routes history={history}>
      {
        routes.map(
          (route) => <Route key={route.path} path={route.path} Component={() => {
            document.title = route.meta.title
            
            return <route.component/>
          }}></Route>
        )
      }
      {/* 重定向 */}
      <Route path="*" element={<Navigate to="/404" />} />
    </Routes>
  </>
}

export default memo(Router)
// export default Router